package date0702am;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcTest05 {

	public static void main(String[] args) throws ClassNotFoundException , SQLException {
		
		String driverClassName = "com.mysql.cj.jdbc.Driver"  ;
		String url = "jdbc:mysql://localhost:3306/ecut?serverTimezone=Asia/Shanghai&useSSL=false" ;
		String user = "ecuter" ;
		String password = "ecuter" ;
		
		// 1、加载驱动
		Class.forName( driverClassName );
		
		// 2、获得连接
		Connection connection = DriverManager.getConnection(url, user, password);
		
		// 3、获得Statement对象
		Statement statement = connection.createStatement();
		
		// 以下DDL语句仅针对 MySQL ，不针对 Oracle
		String DDL = "CREATE TABLE t_users ( id INT(5) auto_increment , name VARCHAR(20) , PRIMARY KEY( id ) )" ; 
		
		// 4、"执行"SQL语句
		int x = statement.executeUpdate( DDL );
		
		// 5、处理返回结果
		System.out.println( "DDL执行后的返回结果: " + x );
		
		// 6、释放资源
		statement.close();
		connection.close();

	}

}
